package com.woniu.apiImpl;
import com.woniu.api.StockApi;
import com.woniu.dto.PageDTO;
import com.woniu.dto.StockDto;
import com.woniu.param.AddDrugsParam;
import com.woniu.param.DeleteParam;
import com.woniu.param.QueryPageParam;
import com.woniu.param.StockParam;
import com.woniu.service.IHisStockService;
import com.woniu.util.Result;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2021-11-11
 */
@RestController
@RequestMapping("/drugs")
public class HisStockApiImpl implements StockApi {

    @Resource
    private IHisStockService iHisStockService;
    @Override
    public Result<PageDTO<StockDto>> getStock(QueryPageParam queryPageParam) {

        PageDTO<StockDto> stockList = iHisStockService.getStockList(queryPageParam);

        return Result.bulid(stockList);
    }

    @Override
    public Result<StockDto> updateStock(StockParam stockParam) {
        StockDto stockDto = iHisStockService.updateStockList(stockParam);

        return Result.bulid(stockDto);
    }

    @Override
    public Result<StockDto> addStock(AddDrugsParam addDrugsParam) {
        StockDto stockDto = iHisStockService.AddStrok(addDrugsParam);
        return Result.bulid(stockDto);
    }

    @Override
    public Result<?> deleteStock(DeleteParam deleteParam) {
        Boolean aBoolean = iHisStockService.DelStok(deleteParam);

        return Result.bulid().setFlag(aBoolean);
    }
}

